rank of word in permutation